package com.jvm;

import sun.misc.Launcher;

import java.net.URL;
import java.util.stream.Stream;

//类加载器实例
public class TestJDKClassLoader {
    public static void main(String[] args) {
        System.out.println(String.class.getClassLoader());//c的获取不到
        System.out.println(com.sun.crypto.provider.DESKeyFactory.
                class.getClassLoader().getClass().getName());
        System.out.println(TestJDKClassLoader.class.getClassLoader().getClass().getClassLoader());
        System.out.println();
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        ClassLoader extClassloader = systemClassLoader.getParent();
        ClassLoader bootStrapClassLoader = extClassloader.getParent();
        System.out.println("systemClassLoader:" + systemClassLoader);
        System.out.println("extClassloader:" + extClassloader);
        System.out.println("bootStrapClassLoader:" + bootStrapClassLoader);
        System.out.println();
        System.out.println("bootstrapLoader加载以下文件");
        URL[] urLs = Launcher.getBootstrapClassPath().getURLs();
        Stream.of(urLs).forEach(System.out::println);
        System.out.println();
        System.out.println("extClassloader加载以下文件：");
        System.out.println(System.getProperty("java.ext.dirs"));
        System.out.println("appClassLoader加载以下文件：");
        System.out.println(System.getProperty("java.class.path"));
    }
}
